﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Intellisense;
using System.IO;

namespace IntellisenseTest
{
    [TestClass]
    public class SelectedDataGetterTest
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void GetSelectedTaskInfoTestMethod1()
        {
            SelectedDataGetter.GetSelectedTaskInfo("", 0);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void GetSelectedTaskInfoTestMethod2()
        {
            SelectedDataGetter.GetSelectedTaskInfo(null, 0);
        }

        [TestMethod]
        public void GetSelectedTaskInfoTestMethod3()
        {
            SelectedTaskInfo result = SelectedDataGetter.GetSelectedTaskInfo("aaa", 0);
            Assert.IsNull(result);
        }

        [TestMethod]
        public void GetSelectedTaskInfoTestMethod4()
        {
            string target = null;
            using (StreamReader reader = new StreamReader("TestData\\XMLFile1.xml"))
            {
                target = reader.ReadToEnd();
            }

            SelectedTaskInfo result = SelectedDataGetter.GetSelectedTaskInfo(target, 40);
            Assert.IsNull(result);
        }

        [TestMethod]
        public void GetSelectedTaskInfoTestMethod5()
        {
            string target = null;
            using (StreamReader reader = new StreamReader("TestData\\XMLFile1.xml"))
            {
                target = reader.ReadToEnd();
            }

            SelectedTaskInfo result = SelectedDataGetter.GetSelectedTaskInfo(target, 41);
            Assert.AreEqual("Project", result.TaskName);
            Assert.AreEqual(3, result.SettingProperties.Count);
            Assert.AreEqual("/Project", result.ParentXPath);
        }

        [TestMethod]
        public void GetSelectedTaskInfoTestMethod6()
        {
            string target = null;
            using (StreamReader reader = new StreamReader("TestData\\XMLFile1.xml"))
            {
                target = reader.ReadToEnd();
            }

            SelectedTaskInfo result = SelectedDataGetter.GetSelectedTaskInfo(target, 345);
            Assert.AreEqual("PropertyGroup", result.TaskName);
            Assert.AreEqual(0, result.SettingProperties.Count);
            Assert.AreEqual("/Project/PropertyGroup", result.ParentXPath);
        }

        [TestMethod]
        public void GetSelectedTaskInfoTestMethod7()
        {
            string target = null;
            using (StreamReader reader = new StreamReader("TestData\\XMLFile1.xml"))
            {
                target = reader.ReadToEnd();
            }

            SelectedTaskInfo result = SelectedDataGetter.GetSelectedTaskInfo(target, 1073);
            Assert.AreEqual("Project", result.TaskName);
            Assert.AreEqual(3, result.SettingProperties.Count);
            Assert.AreEqual("/Project", result.ParentXPath);
        }
    }
}
